class Solution {
public:
    int m = 0;
    int n = 0;
    int funx[4] = {0,0,-1,1};
    int funy[4] = {-1,1,0,0};
    void fun(vector<vector<char>>& board,int x,int y){
        if(x<0||x>=m||y<0||y>=n){
            return;
        }else if(board[x][y] == '.'){
            return;
        }
        board[x][y] = '.';
        for(int i = 0;i<4;i++)
            fun(board,x+funx[i],y+funy[i]);
    }
    int countBattleships(vector<vector<char>>& board) {
        int ret = 0;
        m = board.size();
        n = board[0].size();
        for(int i = 0;i <m;i++){
            for(int j = 0;j<n;j++){
                if(board[i][j] == 'X'){
                    //ret++;
                    //fun(board,i,j);
                    if((i==0||board[i-1][j] == '.' )&& (j == 0||board[i][j-1] == '.'))
                        ret++;
                }
            }
        }
        return ret;
    }
};